#version 460 core
layout (location = 0) in vec3 mPosition;
out vec4 mOutColor;
//uniform是程序与Shader的通信类型声明
//让程序传递一个如此的矩阵 给点做变换
uniform mat4 transformMatrix;
uniform float _time;

mat4 buildTranslate(float x, float y, float z)
{
    mat4 trans = mat4(1.0,0.0,0.0,0.0,
                      0.0,1.0,1.0,0.0,
                      0.0,0.0,1.0,0.0,
                      x, y, z, 1.0);
    return trans;
}

mat4 buildRotateX(float rad)
{
    mat4 xrot = mat4(1.0,0.0,0.0,0.0,
                      0.0,cos(rad),-sin(rad),0.0,
                      0.0,sin(rad),cos(rad),0.0,
                      0.0, 0.0, 0.0, 1.0);
    return xrot;
}

mat4 buildRotateY(float rad)
{
    mat4 yrot = mat4(cos(rad),0.0,sin(rad),0.0,
                      0.0,1.0,0.0,0.0,
                      -sin(rad),0.0,cos(rad),0.0,
                      0.0, 0.0, 0.0, 1.0);
    return yrot;
}

mat4 buildRotateZ(float rad)
{
    mat4 zrot = mat4(cos(rad),-sin(rad),0.0,0.0,
                     sin(rad),cos(rad),0.0,0.0,
                     0.0,0.0,1.0,0.0,
                     0.0, 0.0, 0.0, 1.0);
    return zrot;
}

mat4 buildScale(float x, float y, float z)
{
    mat4 scale = mat4(x,0.0,0.0,0.0,
                      0.0,y,1.0,0.0,
                      0.0,0.0,z,0.0,
                      0, 0, 0, 1.0);
    return scale;
}

void main()
{
   // gl_Position = transformMatrix * vec4(mPosition, 1);//决定了顶点的位置 齐次裁剪坐标下
    mat4 rotX = buildRotateZ(_time * 0.0174f);
    gl_Position = rotX * vec4(mPosition, 1);//决定了顶点的位置 齐次裁剪坐标下
    mOutColor = vec4(mPosition.x +0.3, mPosition.y , mPosition.z , 1);
}